#include <stdio.h>

double fc(double x) {
    return 2 * x * x * x - 4 * x * x + 3 * x - 6;
}

double binarySearch(double left, double right, double epsilon) {
    double mid;
    while ((right-left)>epsilon) {
        mid = (left + right) / 2;
        double result = fc(mid);
        if (result == 0) {
            return mid;
        } else if (result > 0) {
            right = mid;
        } else {
            left = mid;
        }
    }
    return (left + right) / 2;
}

int main() {
    printf("求方程在(-10, 10)的根\n");
    double left = -10, right = 10;
    double epsilon = 0.0001; // 设置精度
    double root = binarySearch(left, right, epsilon);
    printf("方程的根为: %.2f\n", root);
    
    return 0;
}